package net.huashitong.scheduling.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;

import net.huashitong.scheduling.entity.TownshipCompletion;
import net.huashitong.scheduling.filter.TownshipCompletionFiter;
@Repository
public class TownshipCompletionDao extends StringDao<TownshipCompletion>{
	
	public List<TownshipCompletion> queryIndustryName(){
	GenericQuery query = createQuery("obj");
	query.append("  GROUP BY obj.industryId ");
	return query.listResult();
	}
	public List<TownshipCompletion> queryTownshipCompletionList(TownshipCompletionFiter filter){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.industryId = :industryId").setParam("industryId",filter.getIndustryId());
		if("0".equals(filter.getState())){
			query.append(" and obj.currentMonth = :currentMonth order by cast(obj.cumulative as int) desc").setParam("currentMonth",filter.getDate());
			
		}else if("1".equals(filter.getState())){
			query.append(" and obj.currentMonth = :currentMonth order by cast(obj.ratio as int) desc").setParam("currentMonth",filter.getDate());
		}
		return query.listResult();
	}
}
